<%@page language="java" contentType="text/html; charset=utf-8"%>
<%@include file="/commons/inc.jsp" %>

<script>
function show(id){
	var r;
	if(id==1){
		r = '<s:property value='family.diabetesrelate1'/>';
	}else if(id==2){
		r = '<s:property value='family.diabetesrelate2'/>';
	}else if(id==3){
		r = '<s:property value='family.diabetesrelate3'/>';
	}else if(id==4){
		r = '<s:property value='family.diabetesrelate4'/>';
	}else if(id=='h'){
		r = '<s:property value='family.highbloodrelate'/>';
	}else if(id=='l'){
		r = '<s:property value='family.lipidsrelate'/>';
	}else if(id=='g'){
		r = '<s:property value='family.geneticrelate'/>';
	}else if(id=='n'){
		r = '<s:property value='family.nxgrelate'/>';
	}else if(id=='x'){
		r = '<s:property value='family.gxbrelate'/>';
	}
	if(r!=null && r!=''){
		r = r.split(",");
		if(id=='1' || id=='2' || id=='3' || id=='4' ){
			for(var i=0;i<r.length;i++){
				$('d'+id+r[i].trim()).checked=true;
			}
		}else{
			for(var i=0;i<r.length;i++){
				$(id+r[i].trim()).checked=true;
			}
		}
	}
}
</script>

<h3 id="navTitleId">家族史</h3>

<body id="body">

<%@include file="/commons/showmessage.jsp" %>

<form name="familyform" id="familyform" method="post" action="${contextPath}/family/family.action?method=saveEditFamily">
	<s:hidden name="family.familyid" id="family.familyid"></s:hidden>
	<s:hidden name="family.patientid" id="family.patientid"></s:hidden>
	<s:hidden name="patientid" id="patientid"></s:hidden>
	
	<table border="0" cellspacing="1" cellpadding="0" class="formTable" width="100%" >
		<tr>
			<td class="form-td"><label class="label">糖尿病病史:</label></td>
			<td class="form-td">
				<select name="family.diabetes" id="family.diabetes" onchange="javascript:has(1);">
					<option value="0" <s:if test="family.diabetes == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.diabetes == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.diabetes == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.diabetes == 3">selected</s:if>>不详</option>
				</select></td>	
			<td class="form-td"><label class="label">类型:</label>
				<input style="vertical-align:top;" type="radio" name="family.diabetes1" id="family.diabetes1" <s:if test="family.diabetes1==1">checked</s:if> value="1" onclick="javascript:sel(1,this);"/>1型
				<input style="vertical-align:top;" type="radio" name="family.diabetes2" id="family.diabetes2" <s:if test="family.diabetes1!=1 && family.diabetes2==1">checked</s:if> value="1" onclick="javascript:sel(2,this);"/>2型
				<input style="vertical-align:top;" type="radio" name="family.diabetes3" id="family.diabetes3" <s:if test="family.diabetes1!=1 && family.diabetes2!=1 && family.diabetes3==1">checked</s:if> value="1" onclick="javascript:sel(3,this);"/>妊娠糖尿病
				<input style="vertical-align:top;" type="radio" name="family.diabetes4" id="family.diabetes4" <s:if test="family.diabetes1!=1 && family.diabetes2!=1 && family.diabetes3!=1 && family.diabetes4==1">checked</s:if> value="1" onclick="javascript:sel(4,this);"/>其他:
				<input type="text" name="family.diabetes4name" id="family.diabetes4name" value="${family.diabetes4name}" <s:if test="family.diabetes4==null || family.diabetes4==0">disable="disabled"</s:if> size="5"/></td>	
			<td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label> </td>
			 <td class="form-td">
			 <div id="r1">
				<input name="family.diabetesrelate1" type="checkbox" value="1" id="d11"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.diabetesrelate1" type="checkbox" value="2" id="d12"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.diabetesrelate1" type="checkbox" value="3" id="d13"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.diabetesrelate1" type="checkbox" value="4" id="d14"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.diabetesrelate1" type="checkbox" value="5" id="d15"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.diabetesrelate1" type="checkbox" value="6" id="d16"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('1')</script>
			 </div>
			 <div id="r2" style="display:none">
				<input name="family.diabetesrelate2" type="checkbox" value="1" id="d21"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.diabetesrelate2" type="checkbox" value="2" id="d22"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.diabetesrelate2" type="checkbox" value="3" id="d23"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.diabetesrelate2" type="checkbox" value="4" id="d24"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.diabetesrelate2" type="checkbox" value="5" id="d25"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.diabetesrelate2" type="checkbox" value="6" id="d26"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('2')</script>
			 </div>
			  <div id="r3" style="display:none">
				<input name="family.diabetesrelate3" type="checkbox" value="1" id="d31"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.diabetesrelate3" type="checkbox" value="2" id="d32"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.diabetesrelate3" type="checkbox" value="3" id="d33"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.diabetesrelate3" type="checkbox" value="4" id="d34"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.diabetesrelate3" type="checkbox" value="5" id="d35"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.diabetesrelate3" type="checkbox" value="6" id="d36"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('3')</script>
			 </div>
			  <div id="r4" style="display:none">
				<input name="family.diabetesrelate4" type="checkbox" value="1" id="d41"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.diabetesrelate4" type="checkbox" value="2" id="d42"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.diabetesrelate4" type="checkbox" value="3" id="d43"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.diabetesrelate4" type="checkbox" value="4" id="d44"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.diabetesrelate4" type="checkbox" value="5" id="d45"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.diabetesrelate4" type="checkbox" value="6" id="d46"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('4')</script>
			 </div>
			</td>	
		</tr>
	
		<tr>
			<td class="form-td"><label class="label">血脂异常疾病史:</label></td>
			<td class="form-td"><select name="family.lipids" id="family.lipids" onchange="javascript:has(3);">
					<option value="0" <s:if test="family.lipids == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.lipids == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.lipids == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.lipids == 3">selected</s:if>>不详</option>
				</select></td>
			<td class="form-td"><label class="label">病名:</label>
				<input name="family.lipidsname" id="family.lipidsname" type="text" value="${family.lipidsname}"></td>
			<td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label></td>
			<td class="form-td">
			 	<input name="family.lipidsrelate" type="checkbox" value="1" id="l1"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.lipidsrelate" type="checkbox" value="2" id="l2"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.lipidsrelate" type="checkbox" value="3" id="l3"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.lipidsrelate" type="checkbox" value="4" id="l4"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.lipidsrelate" type="checkbox" value="5" id="l5"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.lipidsrelate" type="checkbox" value="6" id="l6"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('l')</script></td>
		</tr>

		<tr>
			<td class="form-td"><label class="label">高血压病史:</label></td>
			<td class="form-td"><select name="family.highblood" id="family.highblood" onchange="javascript:has(2);">
					<option value="0" <s:if test="family.highblood == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.highblood == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.highblood == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.highblood == 3">selected</s:if>>不详</option>
				</select></td>
			<td class="form-td"></td>
			 <td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label></td>
			 <td class="form-td">
			 	<input name="family.highbloodrelate" type="checkbox" value="1" id="h1"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.highbloodrelate" type="checkbox" value="2" id="h2"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.highbloodrelate" type="checkbox" value="3" id="h3"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.highbloodrelate" type="checkbox" value="4" id="h4"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.highbloodrelate" type="checkbox" value="5" id="h5"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.highbloodrelate" type="checkbox" value="6" id="h6"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('h')</script></td>	 	
		</tr>
		<tr>
			<td class="form-td"><label class="label">脑血管疾病史:</label></td>
			<td class="form-td"><select name="family.naoxueguan" id="family.naoxueguan" onchange="javascript:has(5);">
					<option value="0" <s:if test="family.naoxueguan == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.naoxueguan == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.naoxueguan == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.naoxueguan == 3">selected</s:if>>不详</option>
				</select></td>
			<td class="form-td"></td>
			 <td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label></td>
			 <td class="form-td">
			 	<input name="family.nxgrelate" type="checkbox" value="1" id="n1"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.nxgrelate" type="checkbox" value="2" id="n2"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.nxgrelate" type="checkbox" value="3" id="n3"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.nxgrelate" type="checkbox" value="4" id="n4"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.nxgrelate" type="checkbox" value="5" id="n5"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.nxgrelate" type="checkbox" value="6" id="n6"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('n')</script></td>	 	
		</tr>
		<tr>
			<td class="form-td"><label class="label">冠心病、心梗病史:</label></td>
			<td class="form-td"><select name="family.guanxinbin" id="family.guanxinbin" onchange="javascript:has(6);">
					<option value="0" <s:if test="family.guanxinbin == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.guanxinbin == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.guanxinbin == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.guanxinbin == 3">selected</s:if>>不详</option>
				</select></td>
			<td class="form-td"></td>
			 <td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label></td>
			 <td class="form-td">
			 	<input name="family.gxbrelate" type="checkbox" value="1" id="x1"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.gxbrelate" type="checkbox" value="2" id="x2"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.gxbrelate" type="checkbox" value="3" id="x3"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.gxbrelate" type="checkbox" value="4" id="x4"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.gxbrelate" type="checkbox" value="5" id="x5"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.gxbrelate" type="checkbox" value="6" id="x6"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('x')</script></td>	 	
		</tr>
	
		<tr>
			<td class="form-td"><label class="label">其他遗传性疾病史:</label></td>
			<td class="form-td"><select name="family.genetic" id="family.genetic" onchange="javascript:has(4);">
					<option value="0" <s:if test="family.genetic == 0">selected</s:if>>请选择</option>
					<option value="1" <s:if test="family.genetic == 1">selected</s:if>>无</option>
					<option value="2" <s:if test="family.genetic == 2">selected</s:if>>有</option>
					<option value="3" <s:if test="family.genetic == 3">selected</s:if>>不详</option>
				</select></td>
			<td class="form-td"><label class="label">病名:</label>
				<input name="family.geneticname" id="family.geneticname" type="text" value="${family.geneticname}"></td>
			<td class="form-td"><label class="label"><font style="vertical-align:bottom;">关系:</font></label></td>
			<td class="form-td">
			 	<input name="family.geneticrelate" type="checkbox" value="1" id="g1"/><font style="vertical-align:bottom;">祖父母</font>
			 	<input name="family.geneticrelate" type="checkbox" value="2" id="g2"><font style="vertical-align:bottom;">外祖父母</font>
			 	<input name="family.geneticrelate" type="checkbox" value="3" id="g3"><font style="vertical-align:bottom;">父亲</font>
			 	<input name="family.geneticrelate" type="checkbox" value="4" id="g4"><font style="vertical-align:bottom;">母亲</font>
			 	<input name="family.geneticrelate" type="checkbox" value="5" id="g5"><font style="vertical-align:bottom;">兄弟姐妹</font>
			 	<input name="family.geneticrelate" type="checkbox" value="6" id="g6"><font style="vertical-align:bottom;">子女</font>
			 	<script>show('g')</script></td>
		</tr>
		<tr>
			<td align="center" colspan="5"> 
			<input type="reset" value="重置"> 
		    <input type="button" onclick="saveEdit('save');" value="保存">
		    <input type="button" onclick="javascript:back();"value="返回列表"></td>
		</tr>
	</table>
</form>

<%@include file="/commons/tableSel.jsp" %>

</body>

<style type="text/css">
body {
	height: 100%;
	width: 100%;
}
</style>

<script>
function back(){
	location.href="${contextPath}/patient/patient.action?method=query";
}
function saveEdit(type){
	if(type=='refresh'){
		location.reload();
	}else if(type=='save'){
		if(!Validator.Validate($('familyform'),3)){
			return;
		}
		$('familyform').submit();
	}
}
function sel(id,obj){
	for(var i=1;i<5;i++){
		if(i == id){
			$('r'+i).style.display="";	
		}else{
			$('r'+i).style.display="none";
		}
	}
	if (obj.tag==1){
		obj.checked=false;
		obj.tag=0;
	}else{
		obj.checked=true;
		obj.tag=1;
	}
	if(!obj.checked){
		for(var i=1;i<7;i++){
			$('d'+id+i).checked=false;
		}
		if(id==4){
			$('family.diabetes4name').value="";
		}
	}
}
function has(id){
	if(id==1){
		if($('family.diabetes').value==0){
			$('family.diabetes4name').value="";
			for(var i=1;i<5;i++){
				$('family.diabetes'+i).checked = false;
				for(var j=1;j<7;j++){
					$('d'+i+j).checked = false;
				}
			}
		}
	}else if(id==2){
		if($('family.highblood').value==0){
			for(var i=1;i<7;i++){
				$('h'+i).checked = false;
			}
		}
	}else if(id==3){
		if($('family.lipids').value==0){
			$('family.lipidsname').value="";
			for(var i=1;i<7;i++){
				$('l'+i).checked = false;
			}
		}
	}else if(id==4){
		if($('family.genetic').value==0){
			$('family.geneticname').value="";
			for(var i=1;i<7;i++){
				$('g'+i).checked = false;
			}
		}
	}else if(id==5){
		if($('family.naoxueguan').value==0){
			for(var i=1;i<7;i++){
				$('n'+i).checked = false;
			}
		}
	}else if(id==6){
		if($('family.guanxinbin').value==0){
			for(var i=1;i<7;i++){
				$('x'+i).checked = false;
			}
		}
	}
}
</script>